package com.travel.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.travel.mapper.VenueMapper;
import com.travel.pojo.VenueShop;
import com.travel.service.VenueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class VenueServiceImpl extends ServiceImpl<VenueMapper, VenueShop> implements VenueService {
    @Autowired
    private VenueMapper venueMapper;
    public List<StringBuilder> processVenueShopList(List<VenueShop> shopList){
        List<Map<String, Object>> mapList = venueMapper.getLabels();
        List<StringBuilder> stringBuilders = new ArrayList<>();
        for (VenueShop venueShop : shopList) {
            StringBuilder builder = new StringBuilder();
            builder.append(venueShop);
            for (Map<String, Object> label : mapList) {
                int id = (int) label.get("shop_id");
                if (id == venueShop.getId()) {
                    builder.append(",").append(label.get("label_name"));
                }
            }
            stringBuilders.add(builder);
        }
        return stringBuilders;
    }
}
